#include "game.h"

menu()
{
	printf("                           \n");
	printf("       按1开始游戏         \n");
	printf("       按0结束游戏         \n");
	printf("                           \n");
}

void game()
{
	//存储数据
	char a[HAN][LIE];
	//初始化棋盘
	chess(a,HAN,LIE);
	//打印棋盘
	my_print(a,HAN,LIE);
	char x = 0;
	while (1)
	{
		//玩家输入
		player(a, HAN, LIE);
		//判断是否获胜
		x=judje(a,HAN,LIE);
		if (x != 'C')
			break;
		//电脑输入
		com(a, HAN, LIE);
		judje(a, HAN, LIE);
		if (x != 'C')
			break;
	}
	if (x == '#')
	{
		printf("玩家赢了");
	}
	if(x=='&')
	{
		printf("电脑赢了");
	}
	if(x=='Q')
	{
		printf("平局");
	}
}

int main()
{
	int c = 0;
	srand((unsigned int)time (NULL));
	while (1)
	{
		menu();
		scanf("%d", &c);
		if (c == 1)
		{
			game();
		}
		else if (c == 0)
		{
			break;
		}
		else
			printf("请重新输入");
	}
	return 0;
}